//
//  LGMineHomeFooterView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/10.
//

#import "LGMineHomeFooterView.h"

@interface LGMineHomeFooterView()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;

@end

@implementation LGMineHomeFooterView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.titleLabel];
        [self createItemButton];
    }
    return self;
}

-(void)itemButtonTouchAction:(UIButton *)sender{
    if(self.delegate && [self.delegate respondsToSelector:@selector(commonToolItemTouched:)]){
        [self.delegate commonToolItemTouched:sender.titleLabel.text];
    }
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"常用工具" colorString:@"#333333" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(4), viewPix(20), viewPix(150), viewPix(25));
    }
    return _titleLabel;
}

-(void)createItemButton{
    CGFloat itemTop = kMaxY(self.titleLabel.frame);
    CGFloat item_W = (Screen_W-viewPix(24))/4.0;
    CGFloat item_H = viewPix(80);
    NSArray *itemArray = @[@"我的团队",@"快捷回复",@"操作指南",@"上传报告",@"设置"];
    for (NSInteger i = 0; i<itemArray.count; i++) {
        UIButton *button = [UIButton buttonWithTitle:itemArray[i] titleFont:LGFont(14) textColor:@"#333333" imageName:[NSString stringWithFormat:@"我的-%@",itemArray[i]]];
        button.frame = CGRectMake(item_W*(i%4)-viewPix(5), itemTop+item_H*(i/4), item_W, item_H);
        [button setButtonInsetsStyle:LGButtonInsetsStyleTop marginSpace:12];
        [button addTarget:self action:@selector(itemButtonTouchAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
}


@end
